<!DOCTYPE html><html><head>
<title>gpx - GPS eXchange Format (GPX)</title>
<style type="text/css"><!--
    HTML {
	background: 	#FFFFFF;
	color: 		black;
    }
    BODY {
	background: 	#FFFFFF;
	color:	 	black;
    }
    DIV.doctools {
	margin-left:	10%;
	margin-right:	10%;
    }
    DIV.doctools H1,DIV.doctools H2 {
	margin-left:	-5%;
    }
    H1, H2, H3, H4 {
	margin-top: 	1em;
	font-family:	sans-serif;
	font-size:	large;
	color:		#005A9C;
	background: 	transparent;
	text-align:		left;
    }
    H1.doctools_title {
	text-align: center;
    }
    UL,OL {
	margin-right: 0em;
	margin-top: 3pt;
	margin-bottom: 3pt;
    }
    UL LI {
	list-style: disc;
    }
    OL LI {
	list-style: decimal;
    }
    DT {
	padding-top: 	1ex;
    }
    UL.doctools_toc,UL.doctools_toc UL, UL.doctools_toc UL UL {
	font:		normal 12pt/14pt sans-serif;
	list-style:	none;
    }
    LI.doctools_section, LI.doctools_subsection {
	list-style: 	none;
	margin-left: 	0em;
	text-indent:	0em;
	padding: 	0em;
    }
    PRE {
	display: 	block;
	font-family:	monospace;
	white-space:	pre;
	margin:		0%;
	padding-top:	0.5ex;
	padding-bottom:	0.5ex;
	padding-left:	1ex;
	padding-right:	1ex;
	width:		100%;
    }
    PRE.doctools_example {
	color: 		black;
	background: 	#f5dcb3;
	border:		1px solid black;
    }
    UL.doctools_requirements LI, UL.doctools_syntax LI {
	list-style: 	none;
	margin-left: 	0em;
	text-indent:	0em;
	padding:	0em;
    }
    DIV.doctools_synopsis {
	color: 		black;
	background: 	#80ffff;
	border:		1px solid black;
	font-family:	serif;
	margin-top: 	1em;
	margin-bottom: 	1em;
    }
    UL.doctools_syntax {
	margin-top: 	1em;
	border-top:	1px solid black;
    }
    UL.doctools_requirements {
	margin-bottom: 	1em;
	border-bottom:	1px solid black;
    }
--></style>
</head>
<!-- Generated from file 'gpx.man' by tcllib/doctools with format 'html'
   -->
<!-- Copyright &amp;copy; 2010, Keith Vetter &amp;lt;kvetter@gmail.com&amp;gt;
   -->
<!-- gpx.n
   -->
<body><hr> [
   <a href="../../../../../../../../home">Tcllib Home</a>
&#124; <a href="../../../../toc.html">Main Table Of Contents</a>
&#124; <a href="../../../toc.html">Table Of Contents</a>
&#124; <a href="../../../../index.html">Keyword Index</a>
&#124; <a href="../../../../toc0.html">Categories</a>
&#124; <a href="../../../../toc1.html">Modules</a>
&#124; <a href="../../../../toc2.html">Applications</a>
 ] <hr>
<div class="doctools">
<h1 class="doctools_title">gpx(n) 0.9 tcllib &quot;GPS eXchange Format (GPX)&quot;</h1>
<div id="name" class="doctools_section"><h2><a name="name">Name</a></h2>
<p>gpx - Extracts waypoints, tracks and routes from GPX files</p>
</div>
<div id="toc" class="doctools_section"><h2><a name="toc">Table Of Contents</a></h2>
<ul class="doctools_toc">
<li class="doctools_section"><a href="#toc">Table Of Contents</a></li>
<li class="doctools_section"><a href="#synopsis">Synopsis</a></li>
<li class="doctools_section"><a href="#section1">Description</a></li>
<li class="doctools_section"><a href="#section2">COMMANDS</a></li>
<li class="doctools_section"><a href="#section3">DATA STRUCTURES</a></li>
<li class="doctools_section"><a href="#section4">EXAMPLE</a></li>
<li class="doctools_section"><a href="#section5">REFERENCES</a></li>
<li class="doctools_section"><a href="#section6">AUTHOR</a></li>
<li class="doctools_section"><a href="#section7">Bugs, Ideas, Feedback</a></li>
<li class="doctools_section"><a href="#keywords">Keywords</a></li>
<li class="doctools_section"><a href="#category">Category</a></li>
<li class="doctools_section"><a href="#copyright">Copyright</a></li>
</ul>
</div>
<div id="synopsis" class="doctools_section"><h2><a name="synopsis">Synopsis</a></h2>
<div class="doctools_synopsis">
<ul class="doctools_requirements">
<li>package require <b class="pkgname">Tcl 8.5</b></li>
<li>package require <b class="pkgname">gpx <span class="opt">?0.9?</span></b></li>
</ul>
<ul class="doctools_syntax">
<li><a href="#1"><b class="cmd">::gpx::Create</b> <i class="arg">gpxFilename</i> <span class="opt">?<i class="arg">rawXML</i>?</span></a></li>
<li><a href="#2"><b class="cmd">::gpx::Cleanup</b> <i class="arg">token</i></a></li>
<li><a href="#3"><b class="cmd">::gpx::GetGPXMetadata</b> <i class="arg">token</i></a></li>
<li><a href="#4"><b class="cmd">::gpx::GetWaypointCount</b> <i class="arg">token</i></a></li>
<li><a href="#5"><b class="cmd">::gpx::GetAllWaypoints</b> <i class="arg">token</i></a></li>
<li><a href="#6"><b class="cmd">::gpx::GetTrackCount</b> <i class="arg">token</i></a></li>
<li><a href="#7"><b class="cmd">::gpx::GetTrackMetadata</b> <i class="arg">token</i> <i class="arg">whichTrack</i></a></li>
<li><a href="#8"><b class="cmd">::gpx::GetTrackPoints</b> <i class="arg">token</i> <i class="arg">whichTrack</i></a></li>
<li><a href="#9"><b class="cmd">::gpx::GetRouteCount</b> <i class="arg">token</i></a></li>
<li><a href="#10"><b class="cmd">::gpx::GetRouteMetadata</b> <i class="arg">token</i> <i class="arg">whichRoute</i></a></li>
<li><a href="#11"><b class="cmd">::gpx::GetRoutePoints</b> <i class="arg">token</i> <i class="arg">whichRoute</i></a></li>
</ul>
</div>
</div>
<div id="section1" class="doctools_section"><h2><a name="section1">Description</a></h2>
<p>This module parses and extracts waypoints, tracks, routes and
metadata from a GPX (GPS eXchange) file. Both GPX version 1.0
and 1.1 are supported.</p>
</div>
<div id="section2" class="doctools_section"><h2><a name="section2">COMMANDS</a></h2>
<dl class="doctools_definitions">
<dt><a name="1"><b class="cmd">::gpx::Create</b> <i class="arg">gpxFilename</i> <span class="opt">?<i class="arg">rawXML</i>?</span></a></dt>
<dd><p>The <b class="cmd">::gpx::Create</b> is the first command called to process GPX
data. It takes the GPX data from either the <i class="arg">rawXML</i>
parameter if present or from the contents of <i class="arg">gpxFilename</i>,
and parses it using <em>tdom</em>. It returns a token value that is used
by all the other commands.</p></dd>
<dt><a name="2"><b class="cmd">::gpx::Cleanup</b> <i class="arg">token</i></a></dt>
<dd><p>This procedure cleans up resources associated with <i class="arg">token</i>.
It is <em>strongly</em> recommended that you call this
function after you are done with a given GPX file.
Not doing so will result in memory not being freed, and
if your app calls <b class="cmd">::gpx::Create</b> enough times, the
memory leak could cause a performance hit...or worse.</p></dd>
<dt><a name="3"><b class="cmd">::gpx::GetGPXMetadata</b> <i class="arg">token</i></a></dt>
<dd><p>This procedure returns a dictionary of the metadata
associated with the GPX data identified by <i class="arg">token</i>.
The format of the metadata dictionary is described
below, but keys <em>version</em> and <em>creator</em>
will always be present.</p></dd>
<dt><a name="4"><b class="cmd">::gpx::GetWaypointCount</b> <i class="arg">token</i></a></dt>
<dd><p>This procedure returns the number of waypoints defined in the GPX
data identified by <i class="arg">token</i>.</p></dd>
<dt><a name="5"><b class="cmd">::gpx::GetAllWaypoints</b> <i class="arg">token</i></a></dt>
<dd><p>This procedure returns the a list of waypoints defined in the GPX
data identified by <i class="arg">token</i>. The format of each waypoint item
is described below.</p></dd>
<dt><a name="6"><b class="cmd">::gpx::GetTrackCount</b> <i class="arg">token</i></a></dt>
<dd><p>This procedure returns the number of tracks defined in the GPX
data identified by <i class="arg">token</i>.</p></dd>
<dt><a name="7"><b class="cmd">::gpx::GetTrackMetadata</b> <i class="arg">token</i> <i class="arg">whichTrack</i></a></dt>
<dd><p>This procedure returns a dictionary of the metadata
associated track number <i class="arg">whichTrack</i> (1 based) in
the GPX data identified by <i class="arg">token</i>.
The format of the metadata dictionary is described below.</p></dd>
<dt><a name="8"><b class="cmd">::gpx::GetTrackPoints</b> <i class="arg">token</i> <i class="arg">whichTrack</i></a></dt>
<dd><p>The procedure returns a list of track points comprising track
number <i class="arg">whichTrack</i> (1 based) in the GPX data identified by
<i class="arg">token</i>. The format of the metadata dictionary is described below.</p></dd>
<dt><a name="9"><b class="cmd">::gpx::GetRouteCount</b> <i class="arg">token</i></a></dt>
<dd><p>This procedure returns the number of routes defined in the GPX
data identified by <i class="arg">token</i>.</p></dd>
<dt><a name="10"><b class="cmd">::gpx::GetRouteMetadata</b> <i class="arg">token</i> <i class="arg">whichRoute</i></a></dt>
<dd><p>This procedure returns a dictionary of the metadata
associated route number <i class="arg">whichRoute</i> (1 based) in
the GPX data identified by <i class="arg">token</i>.
The format of the metadata dictionary is described below.</p></dd>
<dt><a name="11"><b class="cmd">::gpx::GetRoutePoints</b> <i class="arg">token</i> <i class="arg">whichRoute</i></a></dt>
<dd><p>The procedure returns a list of route points comprising route
number <i class="arg">whichRoute</i> (1 based) in the GPX data identified by
<i class="arg">token</i>. The format of the metadata dictionary is described below.</p></dd>
</dl>
</div>
<div id="section3" class="doctools_section"><h2><a name="section3">DATA STRUCTURES</a></h2>
<dl class="doctools_definitions">
<dt>metadata dictionary</dt>
<dd><p>The metadata associated with either the GPX document, a
track, a route, a waypoint, a track point or route
point is returned in a dictionary. The keys of that
dictionary will be whatever optional GPX elements are
present. The value for each key depends on the GPX schema
for that element. For example, the value for a version
key will be a string, while for a link key will be
a sub-dictionary with keys <em>href</em> and optionally
<em>text</em> and <em>type</em>.</p></dd>
<dt>point item</dt>
<dd><p>Each item in a track or route list of points consists of
a list of three elements: <em>latitude</em>, <em>longitude</em> and
<em>metadata dictionary</em>. <em>Latitude</em> and <em>longitude</em>
are decimal numbers. The <em>metadata dictionary</em> format is
described above. For points in a track, typically there will
always be ele (elevation) and time metadata keys.</p></dd>
</dl>
</div>
<div id="section4" class="doctools_section"><h2><a name="section4">EXAMPLE</a></h2>
<pre class="doctools_example">
% set token [::gpx::Create myGpxFile.gpx]
% set version [dict get [::gpx::GetGPXMetadata $token] version]
% set trackCnt [::gpx::GetTrackCount $token]
% set firstPoint [lindex [::gpx::GetTrackPoints $token 1] 0]
% lassign $firstPoint lat lon ptMetadata
% puts &quot;first point in the first track is at $lat, $lon&quot;
% if {[dict exists $ptMetadata ele]} {
     puts &quot;at elevation [dict get $ptMetadata ele] meters&quot;
  }
% ::gpx::Cleanup $token
</pre>
</div>
<div id="section5" class="doctools_section"><h2><a name="section5">REFERENCES</a></h2>
<ol class="doctools_enumerated">
<li><p>GPX: the GPS Exchange Format
   (<a href="http://www.topografix.com/gpx.asp">http://www.topografix.com/gpx.asp</a>)</p></li>
<li><p>GPX 1.1 Schema Documentation (<a href="http://www.topografix.com/GPX/1/1/">http://www.topografix.com/GPX/1/1/</a>)</p></li>
<li><p>GPX 1.0 Developer's Manual (<a href="http://www.topografix.com/gpx_manual.asp">http://www.topografix.com/gpx_manual.asp</a>)</p></li>
</ol>
</div>
<div id="section6" class="doctools_section"><h2><a name="section6">AUTHOR</a></h2>
<p>Keith Vetter</p>
</div>
<div id="section7" class="doctools_section"><h2><a name="section7">Bugs, Ideas, Feedback</a></h2>
<p>This document, and the package it describes, will undoubtedly contain
bugs and other problems.
Please report such in the category <em>gpx</em> of the
<a href="http://core.tcl.tk/tcllib/reportlist">Tcllib Trackers</a>.
Please also report any ideas for enhancements you may have for either
package and/or documentation.</p>
<p>When proposing code changes, please provide <em>unified diffs</em>,
i.e the output of <b class="const">diff -u</b>.</p>
<p>Note further that <em>attachments</em> are strongly preferred over
inlined patches. Attachments can be made by going to the <b class="const">Edit</b>
form of the ticket immediately after its creation, and then using the
left-most button in the secondary navigation bar.</p>
</div>
<div id="keywords" class="doctools_section"><h2><a name="keywords">Keywords</a></h2>
<p><a href="../../../../index.html#gps">gps</a>, <a href="../../../../index.html#gpx">gpx</a></p>
</div>
<div id="category" class="doctools_section"><h2><a name="category">Category</a></h2>
<p>File formats</p>
</div>
<div id="copyright" class="doctools_section"><h2><a name="copyright">Copyright</a></h2>
<p>Copyright &copy; 2010, Keith Vetter &lt;kvetter@gmail.com&gt;</p>
</div>
</div></body></html>
